<?php

class LevelChecker
{

	private		$db						=	NULL;
	private		$js						=	NULL;
	private		$LEVEL_ERROR_MESSAGE	= 	"";

	function __construct()
	{
		$this->db = $GLOBALS["db"];
		$this->js = $GLOBALS["JSClass"];
	}

	public function checkLevel($level="",$admin="",$modi="")
	{
		$currentURL = base64_encode(serialize($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']));//unserialize(base64_decode($inString))
		if(empty($_SESSION["check"])){
			if(empty($modi)){
				if($admin==1){
					$this->js->replace("../../login.php?returnUrl=".$currentURL);
				}else{
					$this->js->replace("../login.php?returnUrl=".$currentURL);
				}
			}else{
				$this->js->msg_go();
			}
		}else{
			$check=$_SESSION["check"];
			if($admin==1 && $check<4){
				$this->js->msg_replace(COM_ERR_00015,"../../member/member_account.php");
			}

			if(!($level <= $check)){
				$this->js->msg_go(COM_ERR_00015);
			}
		}

/*
		if($level=="login")
		{
			if(empty($_SESSION['kaiinId']))
			{
				$currentURL = base64_encode(serialize($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']));//unserialize(base64_decode($inString))
				$this->js->replace("../login.php?returnUrl=".$currentURL);
				//$this->js->replace("/jp/ssl/login.php");
			}
		}*/
	}

	public function getSessionInfo(){
		if(!empty($_SESSION['kaiinId']))
		{
			$sql="select * from kaiin where KaiinId = '".$_SESSION['kaiinId']."'";
			$this->db->conn();
			$queryData = $this->db->fetch($sql);
			$this->db->close();
			return $queryData;
		}else{
			$currentURL = base64_encode(serialize($_SERVER['PHP_SELF']."?".$_SERVER['QUERY_STRING']));
			$this->js->replace("../login.php?returnUrl=".$currentURL);
		}
	}
	public function setSessionInfo(){

	}
}

if(!is_object($lc))
{
	$lc = new LevelChecker;
}

?>
